*******************************************************************************
* Specify city and years
*******************************************************************************

local city = "east_baton_rouge"

use dataset_`city'_cross, clear
append using dataset_`city'_cross_pres
replace year = 2000 if year == 2012
replace year = 2010 if year == 2016

local y1 2000
local y2 2010
local y3 2020

*******************************************************************************
* Ref support and percent black
*******************************************************************************

foreach year in `y1' `y2' `y3' {
	
	local mytext
	if `year' == `y1' ///
		local mytext ///
		text(0.25 0.4 "{&larr}Dem. pres vote 2012", col(gray) ///
		size(vsmall))
	if `year' == `y2' ///
		local mytext ///
		text(0.35 0.45 "{&larr}Dem. pres vote 2016", col(gray) ///
		size(vsmall))
	if `year' == `y3' ///
		local mytext ///
		text(0.9 0.55 "Dem. pres vote 2020{&rarr}", col(gray) ///
		size(vsmall))
		
	#delimit;
	
	gr tw
		(sc pctyes pctnhblack if year == `year' [aw=totalvotes], 
			msym(Oh) msize(tiny) col(gray))
		(lpoly pctdem pctnhblack if year == `year' [aw=totalvotes], 
			col(gray) lwid(thin))
		(lpoly pctyes pctnhblack if year == `year' [aw=totalvotes], 
			lcol(black) lwid(thick))
		,
			legend(off)
			plotregion(style(none))
			ylab(, angle(horiz))
			name(g`year', replace)
			title(`year')
			xtitle("")
			ytitle("")
			yline(0.5, lpat(dash))
			`mytext'
			;
			
	#delimit cr
	
	gr close
	
}

gr combine g`y1' g`y2' g`y3', rows(1) xsize(3) ysize(1) ycommon xcommon ///
	b1title("Share Black") ///
	l1title("Share Yes Vote") ///
	imargin(zero) name(a, replace) ///
	title("(a) Police budget support and share black by year.")

gr close

*******************************************************************************
* Ref support and miles from shooting
*******************************************************************************

foreach year in `y1' `y2' `y3' {
	
	#delimit;
	
	gr tw
		(sc pctyes distance if year == `year' [aw=totalvotes], 
			msym(Oh) msize(tiny) col(gray))
		(lpoly pctdem distance if year == `year' [aw=totalvotes], 
			col(gray) lwid(thin))
		(lpoly pctyes distance if year == `year' [aw=totalvotes], 
			lcol(black) lwid(thick))
		,
			legend(off)
			plotregion(style(none))
			ylab(, angle(horiz))
			name(g`year', replace)
			title(`year')
			xtitle("")
			ytitle("")
			yline(0.5, lpat(dash))
			xscale(reverse)
			;
			
	#delimit cr
	
	gr close
	
}

local mytitle = "(b) Police budget support distance to " + ///
	"2016 killing of Alton Sterling."

gr combine g`y1' g`y2' g`y3', rows(1) xsize(3) ysize(1) ycommon xcommon ///
	b1title("Distance to Shooting (Miles)") ///
	l1title("Share Yes Vote") ///
	imargin(zero) name(b, replace) ///
	title("`mytitle'")	

gr close

*******************************************************************************
* Combine
*******************************************************************************	

gr combine a b, rows(2) ysize(1.5) xsize(2)  
gr export "_output/figure 2.eps", replace

*******************************************************************************
* End
*******************************************************************************
